<template>
	<view>
		<view class="searchBox flex">
			<view class="fdjbox">
				<image src="../../static/fdj.png" mode=""></image>
			</view>
			<view class="inpbox">
				<input type="text" value="" v-model="key_words" :placeholder="placeholder"
					placeholder-style="color:#BBBBBB;font-size: 28upx;	margin-top: 4upx;" />

			</view>
		</view>
		<view class="titletext">请选择需要出险的保单</view>
		<view class="itembox" v-for="(item,index) in itemdata" :key="index" @click="navclick(item.id)">
			<view class="bxtitle">{{item.fanan_name}}</view>
			<view class="Insurer">被保险人：{{item.name}}</view>
			<view class="period">保障期限：{{item.start_time}}至{{item.end_time}}</view>
		</view>
		<view class="quesheng" v-if="itemdata.length==0">
			<image style="width: 272rpx;height: 200rpx;" src="../../static/img/baodanquesheng.png" mode=""></image>
			<view class="queshengtext">暂无保单</view>
		</view>
		<view class="jiazai" v-if="isshow">
			我可是有底线的喔~
		</view>
	</view>
</template>

<script>
	import {
		navTo
	} from '@/utils/method.js'
	export default {
		data() {
			return {
				itemdata: [], //初始数据
				key_words: '', //搜索框
				isshow: false, //到底
				placeholder: "输入出险人姓名、身份证号",
				logo: null
			}
		},
		onLoad(option) {
			this.logo = option.id
			if (option.id == 1) {
				this.placeholder = "输入出险人姓名、身份证号"
				this.reportorder()
			} else {
				this.placeholder = "输入企业名称"
				this.reportorder2()
			}
		},
		watch: {
			key_words: {
				handler() {
					if (this.logo == 1) {
						this.reportorder()
					} else {
						this.reportorder2()
					}
				}
			}
		},
		methods: {
			// 进入详情
			navclick(id) {
				let obj = {
					id: id,
					type: 1
				}
				navTo('/pages/registerPath/dataInfo?obj=' + JSON.stringify(obj))
			},
			// 个人
			reportorder(info) {
				this.ajax('claim/userOrder', {
					data: {
						key_words: this.key_words
					},
					success: (res) => {
						console.log(res);
						this.itemdata = res.msg
					}
				})
			},
			// 企业
			reportorder2(info) {
				this.ajax('claim/insureOrder', {
					data: {
						key_words: this.key_words
					},
					success: (res) => {
						console.log(res);
						this.itemdata = res.msg
					}
				})
			}
		}
	}
</script>

<style scoped lang="less">
	.searchBox {
		margin: 30upx 24upx;
		height: 72upx;
		background-color: #fff;
		border-radius: 20upx;

		.fdjbox {
			width: 32upx;
			height: 32upx;

			margin-left: 26upx;

			image {
				width: 32upx;
				height: 32upx;
			}
		}

		.inpbox {
			margin-left: 22upx;

			input {
				width: 580upx;
				font-size: 28upx;
			}
		}
	}

	.titletext {
		margin: 40upx 24upx 0;
		height: 50rpx;
		color: #000000;
		font-size: 32upx;
	}

	.itembox {
		margin: 42upx 24upx 0;
		border-radius: 20upx;
		background-color: #fff;
		position: relative;

		.bxtitle {
			padding-top: 34upx;
			margin-left: 28upx;
			font-size: 32upx;
			color: #000000;
		}

		.Insurer {
			margin: 26upx 28upx 0;
			font-size: 28upx;
			color: #999999;
		}

		.period {
			margin: 26upx 28upx 0;
			padding-bottom: 38upx;
			font-size: 28upx;
			color: #999999;
		}

		.checkbox {
			width: 48upx;
			height: 48upx;
			border: 1px solid #CCCCCC;
			border-radius: 10upx;
			position: absolute;
			right: 36upx;
			top: 92upx;
		}

		.duigoimg {
			width: 50upx;
			height: 50upx;
			position: absolute;
			right: 36upx;
			top: 92upx;
		}
	}

	.butbox {
		margin: 172upx 28upx 60upx;
		height: 100upx;
		background: linear-gradient(180deg, #4EB4FE 0%, #5280F8 100%);
		border-radius: 10upx;
		text-align: center;
		line-height: 100upx;
		color: #fff;
		font-size: 32upx;
		// display: flex;
		// padding: 0 0 30upx 0;
	}

	.jiazai {
		// height: 40upx;
		padding: 20upx 0;
		color: #777777;
		text-align: center;
		font-size: 28upx;
	}
	.quesheng{
		width: 100%;
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		margin-top: 320rpx;
	}
	.queshengtext{
		height: 40rpx;
		font-size: 28rpx;
		font-family: PingFang SC;
		font-weight: 400;
		line-height: 24rpx;
		color: #999999;
		opacity: 1;
	}
</style>